package cn.rkylin.oms.base.returnReasonType.dao;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.base.returnReasonType.domain.ReturnReasonType;
import cn.rkylin.oms.base.returnReasonType.vo.ReturnReasonTypeVO;

/**
 * 退货原因类型访问层
 * 
 * @author qitao
 * @version 1.0
 * @created 17-7月-2017
 */
@Repository(value = "returnReasonTypeDAO")
public class ReturnReasonTypeDAOImpl implements IReturnReasonTypeDAO {

	@Autowired
	protected IDataBaseFactory dao;

	/**
	 * 查询退货原因类型根据退货原因编码
	 * 
	 * @param params
	 *            数据参数
	 */
	public int getReturnReasonTypeCountByCode(Map<String, Object> params) throws Exception {
		List<ReturnReasonType> list = dao.findList("getReturnReasonTypeCountByCode", params);
		if (list.size() > 0) {
			return 1;
		} else {
			return 0;
		}
	}

	/**
	 * 插入退货原因类型
	 * 
	 * @param params
	 *            数据参数
	 */
	public int insertReturnReasonType(Map<String, Object> params) throws Exception {
		return dao.insert("insertReturnReasonType", params);
	}

	/**
	 * 查询退货原因类型
	 * 
	 * @param params
	 *            数据参数
	 */
	public ReturnReasonType getReturnReasonTypeInfo(Map<String, Object> params) throws Exception {
		List<ReturnReasonTypeVO> list = dao.findList("getReturnReasonTypeInfo", params);

		if (list != null && list.size() > 0) {
			return list.get(0);
		}

		return null;
	}

	/**
	 * 修改退货原因类型
	 * 
	 * @param params
	 *            数据参数
	 */
	public int updateReturnReasonType(Map<String, Object> params) throws Exception {
		return dao.update("updateReturnReasonType", params);
	}

	/**
	 * 删除退货原因类型
	 * 
	 * @param params
	 *            数据参数
	 */
	public int deleteReturnReasonType(Map<String, Object> params) throws Exception {
		return dao.update("deleteReturnReasonType", params);
	}

}
